package com.zbest.common.lang.util;

import java.io.Serializable;
import java.util.Arrays;

/**
 * 类Event.java的实现描述：被监听事件
 * 
 * @author skl
 */
public class Event implements Serializable {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 4161755693819623893L;

    /**
     * bean
     */
    private Object            bean;

    /**
     * 方法名
     */
    private String            methodName;

    /**
     * 参数
     */
    private Object[]          args;

    /**
     * 处理类型
     */
    @SuppressWarnings("rawtypes")
    private Class[]           clazzs;

    /**
     * @param bean
     * @param methodName
     * @param args
     */
    public Event(Object bean, String methodName, Object[] args) {
        this.bean = bean;
        this.methodName = methodName;
        if (null != args) {
            this.args = Arrays.copyOf(args, args.length);
        } else {
            this.args = null;
        }
    }

    /**
     * @param bean
     * @param methodName
     * @param args
     * @param clazzs
     */
    public Event(Object bean, String methodName, Object[] args, @SuppressWarnings("rawtypes") Class[] clazzs) {
        this.bean = bean;
        this.methodName = methodName;
        if (null != args) {
            this.args = Arrays.copyOf(args, args.length);
        } else {
            this.args = null;
        }

        if (null != clazzs) {
            this.clazzs = Arrays.copyOf(clazzs, clazzs.length);
        } else {
            this.clazzs = null;
        }
    }

    /**
     * @return
     */
    public Object getBean() {
        return bean;
    }

    /**
     * @param bean
     */
    public void setBean(Object bean) {
        this.bean = bean;
    }

    /**
     * @return
     */
    public String getMethodName() {
        return methodName;
    }

    /**
     * @param methodName
     */
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    /**
     * @return
     */
    public Object[] getArgs() {
        if (null != args) {
            return Arrays.copyOf(args, args.length);
        } else {
            return null;
        }
    }

    /**
     * @param args
     */
    public void setArgs(Object[] args) {
        if (null != args) {
            this.args = Arrays.copyOf(args, args.length);
        } else {
            this.args = null;
        }
    }

    /**
     * @return
     */
    @SuppressWarnings("rawtypes")
    public Class[] getClazzs() {
        if (null != clazzs) {
            return Arrays.copyOf(clazzs, clazzs.length);
        } else {
            return null;
        }
    }

    /**
     * @param clazzs
     */
    public void setClazzs(@SuppressWarnings("rawtypes") Class[] clazzs) {
        if (null != args) {
            this.args = Arrays.copyOf(args, args.length);
        } else {
            this.args = null;
        }
    }
}
